@{ViewBag.Title = "Paging";}
@section CssImport{<link href="@Url.Content("~/Scripts/validationEngine/validationEngine.jquery.css")" rel="stylesheet" type="text/css" />}
@section JavascriptImport{
<script type="text/javascript" src="@Url.Content("~/Scripts/validationEngine/jquery.validationEngine.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/validationEngine/jquery.validationEngine-en.js")"></script>}
<div class="filtering"><form>
<label>Introduzca texto para filtrar: <input type="text" name="filter" id="filter" title="Buscar o Filtrar por Nombre"/></label>
<button type="submit" id="LoadRecordsButton" class="button medium orange" >Buscar Coincidencias</button>
</form></div>
<div id="MyTableContainer"></div>
<script type="text/javascript">
     $(document).ready(function () {
     $('#MyTableContainer').jtable({
         title: 'AIT_EquipoDisponible',
         paging: true,
         pageSize: 10,
         sorting: true,
         defaultSorting: 'Id ASC',
         actions: {
             listAction: '@Url.Action("JSONPagedListByFilter")',
             deleteAction: '@Url.Action("JSONDelete")',
             updateAction: '@Url.Action("JSONUpdate")',
//             createAction: '@Url.Action("JSONCreate")'
         },
         fields:
         {
          Id: {
                 key: true,
                 create: false,
                 edit: false,
                 list: false
             }
             ,
             Guid: {
                 type: 'hidden'
//                 title:'Guid',
//                 create: true,
//                 edit: true,
//                 list: true,
//                 sorting: false
             }
             ,
             Codigo: {
                 title:'Codigo',
                 create: false,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             Nombre: {
                 title:'Nombre',
                 create: false,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             Descripcion: {
                 title:'Descripcion',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             ListoParaEntregar: {
                 title:'ListoParaEntregar',
                 create: false,
                 edit: true,
                 list: true,
                 type: 'checkbox',
                 values:{'false':'Desactivado','true':'Activado'},
                 sorting: false
             }
             ,
             ImprimirCodigos:
             {
                title: 'Generar Codigo de Barras',
                width: '180px',
                sorting: false,
                edit: false,
                create: false,
                listClass: 'child-opener-image-column',
                display: function (tempData) {
                    var $img = $('<img class="child-opener-image" with="30" height="30" src="@Url.Content("~/Content/images/menu/CodigoBarras.png")" title="Generar Codigo de Barras QR" />');
                    $img.click(function () {
                        window.open('/AIT/Reportes/CodigosQR?EquipoId=' + tempData.record.Id);
//                        window.open('/Reportes/CodigosQR?EquipoId=' + tempData.record.Id);
                    });

                    return $img;
                }
            }


},
formCreated: function (event, data) {data.form.validationEngine();},
formSubmitting: function (event, data) {return data.form.validationEngine('validate');},
formClosed: function (event, data) { data.form.validationEngine('hide'); data.form.validationEngine('detach'); }
});
$('#LoadRecordsButton').click(function (e) {e.preventDefault();$('#MyTableContainer').jtable('load', {filter: $('#filter').val()});});
$('#LoadRecordsButton').click();
});
</script>

